using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dapper_Core.Common
{
    public static class VerifyEmptyUtility
    {
        /// <summary>
        /// IEnumerable是否包含数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Source"></param>
        /// <returns></returns>
        public static bool HasData<T>(this IEnumerable<T> Source)
        {
            return null != Source && Source.Any();
        }

        /// <summary>
        /// Dictionary是否包含数据
        /// </summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="Source"></param>
        /// <returns></returns>
        public static bool HasData<TKey, TValue>(this Dictionary<TKey, TValue> Source)
        {
            return null != Source && Source.Any();
        }

        /// <summary>
        /// 字符串是否为空
        /// </summary>
        /// <param name="Source"></param>
        /// <returns></returns>
        public static bool IsEmpty(this String Source)
        {
            if (null == Source)
            {
                return true;
            }
            Source = Source.Trim();
            return Source.Length == 0;
        }

        /// <summary>
        /// Guid?是否为空
        /// </summary>
        /// <param name="Source"></param>
        /// <returns></returns>
        public static bool IsEmpty(this Guid? Source)
        {
            return Source == null || Source == Guid.Empty;
        }
    }
}
